import threading

from spider.movieListSpider import MovieListSpider
from spider.movieSpider import MovieSpider
from constant.config import DYTT_BIKAN_MOVIE, DYTT_CLASSIC_MOVIE, DYTT_NEW_MOVIE


def user_select():
    print('---目前支持以下列表---')
    print('全部电影------------0')
    print('最新电影------------1')
    print('经典电影------------2')
    print('必看电影------------3')
    return input('请输入需要爬取的序号:')


movie_list = [DYTT_NEW_MOVIE, DYTT_CLASSIC_MOVIE, DYTT_BIKAN_MOVIE]

if __name__ == '__main__':

    threads = []
    infoThread = MovieSpider(2)
    infoThread.start()
    thread = MovieListSpider(1, DYTT_NEW_MOVIE)
    thread.start()

    threads.append(thread)
    threads.append(infoThread)

    for i in threads:
        i.join()
    print("退出主线程")
    # type = 0
    # try:
    #     type = int(user_select())
    # except Exception as e:
    #     print("输入类型有误， 请重新输入")
    # if type == 0:
    #     for i in movie_list:
    #         thread = MovieListSpider(1, i)
    #         thread.start()
    #         thread.join()
    # elif type == 1:
    #     thread = MovieListSpider(1, DYTT_NEW_MOVIE)
    #     thread.start()
    # elif type == 2:
    #     thread = MovieListSpider(1, DYTT_CLASSIC_MOVIE)
    #     thread.start()
    # elif type == 3:
    #     thread = MovieListSpider(1, DYTT_BIKAN_MOVIE)
    #     thread.start()
    # else:
    #     thread = MovieListSpider(1, DYTT_NEW_MOVIE)
    #     thread.start()

    # infoThread = MovieSpider(2)
    # infoThread.start()
    # infoThread.join()